home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Graphics / Gallery / Source / ScalePicture.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-20  |  1.5 KB  |  54 lines

  1. #define __VERSION__     "39"
  2. #define __REVISION__     "1"
  3. #define __NAME__            "ScalePicture"
  4. #define __AUTHOR__        "Markus Hillenbrand"
  5.  
  6. #include <stream.h>
  7.  
  8. #include "GUICINCLUDE:GUIC_ProgramArgs.hpp"
  9. #include "GUICINCLUDE:GUIC_Exceptions.hpp"
  10. #include "GUICINCLUDE:GUIC_GGFXPicture.hpp"
  11. #include "GUICINCLUDE:GUIC_System.hpp"
  12.  
  13. /*********************************************************************************************************/
  14.  
  15. STRPTR V = "$VER: " __NAME__ " " __VERSION__ "." __REVISION__ " (" __DATE__ ")";
  16.  
  17. /*********************************************************************************************************/
  18.  
  19. VOID main (LONG argc, STRPTR argv[])
  20. {
  21.     LONG result[] = { 0,0,0,0 };
  22.     STRPTR templ = "FILENAME/A,WIDTH/N/A,HEIGHT/N/A,DESTINATIONFILE=DF/A";
  23.     GUIC_ProgramArgsC args;
  24.     if (! args.fit(templ, result)) { cerr << "Usage: " << templ << endl; return; }
  25.         
  26.     STRPTR    fileName    = (STRPTR) result[0];
  27.     LONG        width        = *(LONG *) result[1];
  28.     LONG        height        = *(LONG *) result[2];
  29.     STRPTR    destFile    = (STRPTR) result[3];
  30.     
  31.     try
  32.         {
  33.         GUIC_GGFXPictureC pic (fileName);
  34.         
  35.         cout << "Loading picture " << fileName << endl;
  36.  
  37.         LONG pWidth = pic.getWidth();
  38.         LONG pHeight = pic.getHeight();
  39.         
  40.         cout << "Picture Dimensions: " << pWidth << " x " << pHeight << endl;
  41.         
  42.         if (pWidth > width || pHeight > height)
  43.             {
  44.             cout << "Scaling picture" << endl;
  45.             pic.scaleToBox (width, height);
  46.             cout << "Saving picture as JPEG (90%)" << endl;
  47.             pic.saveJPEG(destFile, 90);
  48.             }
  49.             
  50.         }
  51.     catch (GUIC_Exception &x) { cerr << x.getMessage() << endl; }
  52. }
  53.  
  54.